﻿#include "stdafx.h"
#include "XCheckBoxIntParser.h"

#include "XBSTR.h"
#include "XString.h"
#include "StrUtil.h"
#include "Util.h"
#include "IXColorDraw.h"
#include "IXImageDraw.h"
#include "IXCheckBox.h"

#include "ParseHelper.h"


CXCheckBoxIntParser::CXCheckBoxIntParser() : CXIntParserBase(&TIntCreateControl<IXCheckBox>)
{
    ;
}

CXCheckBoxIntParser::~CXCheckBoxIntParser()
{
    ;
}

// 填充属性
BOOL CXCheckBoxIntParser::FillAttr(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    BOOL bResult = m_ParentParser.FillAttr(pNode, pControl);
    if(!bResult)
        return bResult;

    XBSTR bstrTemp;

    IXCheckBox* pCheckBox = Util::QueryIntf<IXCheckBox>(pControl);
    if(pCheckBox == NULL)
        return FALSE;

    // Check
    if(SUCCEEDED(pNode->GetValue(_T("check"), &bstrTemp)))
    {
        if(_tcsicmp(bstrTemp, _T("checked")) == 0)
            pCheckBox->put_Check(CBS_Checked);
        else if(_tcsicmp(bstrTemp, _T("unchecked")) == 0)
            pCheckBox->put_Check(CBS_UnChecked);
        else if(_tcsicmp(bstrTemp, _T("intchecked")) == 0)
            pCheckBox->put_Check(CBS_Indeterminate);
    }

    // UnCheckText
    if(SUCCEEDED(pNode->GetValue(_T("uncheckText"), &bstrTemp)))
    {
        XString strTemp(bstrTemp);
//         if(strTemp.size() > 0 && strTemp.at(0) == _T('@'))
//             strTemp = Util::LoadString(strTemp);
        pCheckBox->put_UnCheckText(strTemp.GetData());
    }

    return bResult;
}
